﻿using System;
using System.Collections.Generic;
using System.Web;
using WAD.WEB.AppCode;
using GL.Tools;

namespace WAD.WEB.Admin.Ajax
{
    /// <summary>
    /// Admin 的摘要说明
    /// </summary>
    public class Admin : AdminAjax
    {
        public override void AjaxMethodDispatch(String identity)
        {
            switch (identity)
            {
                case "get": this.Get(); break;
                case "editpass": this.EditPass(); break;
            }
        }
        [QD.Web.Ajax.AjaxMethod]
        public void Get()
        {
            int id = Parse.Int("page_index", 1);
            if (id < 1)
                ParamError();
            JsonResult(0, "", DAL.DAOAdmin.Get(id));
        }

        /// <summary>
        ///  修改会员信息
        /// </summary>
        [QD.Web.Ajax.AjaxMethod]
        public void EditPass()
        {
            int id = Parse.Int("id", 0);//当前页
            string pwd = Parse.String("pwd", "");
            string pwd2 = Parse.String("pwd2", "");
            int state = Parse.Int("state", 0);
            if (id < 1)
                ParamError();

            if (pwd.Length < 1)
                JsonResult(11, "请输入密码");
            if (pwd2.Length < 1)
                JsonResult(11, "请输入确认密码");
            if (!pwd.Equals(pwd2))
                JsonResult(11, "两次密码不一致");

            //验证管理员身份
            DAL.DAOAdmin.EditPass(id, StringHelper.MD5Encrypt(pwd));
            JsonResult(0, "");
        }
    }
}